package com.example.dakotanews.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.dakotanews.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper extends BaseMapper<User> {

    /**
     * @description 重写查找方法，根据用户名查找用户记录
     */
    @Select("SELECT * FROM dakotanews.user WHERE username = #{username}")
    User selectByUsername(String username);

    /**
     * @description 根据用户ID查询用户记录
     * @param userId 用户ID
     * @return 返回一个 用户类
     */
    @Select("select * from dakotanews.user where id = #{userId}")
    User selectById(Integer userId);

}
